#include "WebsocketClient.h"
#include <iostream>
#include <thread>
#include "StreamHandler.hpp"
#include "AvDecoder.h"

using namespace std;

int main(int argc, char const *argv[])
{

    auto handler = make_shared<StreamHandler>();

    handler->open(StreamHandler::TransportType::websocket, "ws://localhost:9002");

    while (!handler->get_connected()){
    }

    cout << "socket opened...." << endl;

    // 解析音频文件
    AvDecoder decoder = AvDecoder("/Users/czi/Desktop/test.pcm");
    int ret = decoder.run(true, [handler](Package &&package) {
        handler->append(std::move(package));
    });

    // handler->close();

    getchar();
    return 0;
}
